<?
    class d_css
    {
        const DEF_HEADER = "'Content-Type: text/css'";

        public $raw;
        public $css;
        public $input_file_name;
        public $output_file_name;

        private  $vars;
        private  $long_pathes;
        private  $extends;

        /**
         * @param $source - raw d.css format
         * @return array - of vars
         * explode all vars and values from source and return array of var=>value pairs
         */
        private function get_vars ($source)
        {
            $vars = array();
            // todo reqex to explode vars and values to array
            return $vars;
        }

        /**
         * @param $source - raw d.css format
         * @return array - of selector-pathes
         * explode long pathes and generate full pathes to selectors
         */
        private function get_long_path ($source)
        {
            $long_pathes = array();
            // todo reqex to explode pathes selector pathes
            return $long_pathes;
        }

        /**
         * @param $source - raw d.css format
         * @return array of extends
         * explode extends and return array of extend
         */
        private function get_extend ($source)
        {
            $extends = array();
            // todo reqex to explode extends
            return $extends;
        }


        public function render()
        {

        }

        public function load($input_file_name)
        {

        }

        public function render_to_file($output_file_name = 'style.css')
        {
            if ((trim($output_file_name) != '') && ($f_css = fopen($output_file_name, 'w+')))
            {
                if ($this->css = $this->render())
                {
                    return true;
                }
                return false;
            }
            // todo error?
            return false;
        }

        public function load_and_render($input_file_name = 'style.d.css', $output_file_name = 'style.css')
        {

        }
        // todo Добавить возможность переопределения переменных на лету
    }